package com.atguigu.sparktuning.cache_01

import com.atguigu.sparktuning.utils.InitUtil
import org.apache.spark.SparkConf
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{Row, SparkSession}

/**
  * @Author  Zhongxu.Zhao
  * @ClassName RddCacheDemo
  * @Date 2021/12/13 23:36
  * @Desc: TODO
 **/
object RddCacheDemo {
  def main(args: Array[String]): Unit = {
    val sparkconf: SparkConf = new SparkConf().setMaster("local").setAppName(this.getClass.getName)
    val spark: SparkSession = InitUtil.initSparkSession(sparkconf)
    import spark.implicits._

    val result: RDD[Row] = spark.sql("select * from sparktuning.course_pay").rdd
    result.cache()
    result.foreachPartition((p:Iterator[Row]) => p.foreach(item => println(item.getString(3))))

    while(true)
    {

    }
  }

}
